package com.xuecheng.media.controller;

import com.xuecheng.api.media.MediaAuditApi;
import com.xuecheng.api.media.model.qo.QueryMediaModel;
import com.xuecheng.api.media.model.vo.MediaAuditVO;
import com.xuecheng.common.domain.page.PageRequestParams;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.media.service.MediaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created on 2021/04/06/9:01 周二
 *
 * @author Lantin
 */
@RestController
public class MediaAuditController implements MediaAuditApi {

    @Autowired
    private MediaService mediaService;

    @PostMapping("m/media/list")
    public PageVO queryAuditMediaList(PageRequestParams params,
                                      @RequestBody QueryMediaModel model) {

        return mediaService.queryMediaList(params, model, null);
    }

    @PutMapping("m/media/audit")
    public boolean auditMedia(@RequestBody MediaAuditVO mediaAuditVO) {

        String auditStatus = mediaAuditVO.getAuditStatus();
        Integer mediaId = mediaAuditVO.getId();
        String auditMind = mediaAuditVO.getAuditMind();

        return mediaService.auditMedia(mediaId, auditStatus, auditMind);
    }

    @GetMapping("m/media/preview/{mediaId}")
    public String previewMedia(@PathVariable Long mediaId) {


        return mediaService.previewMedia(mediaId, null);
    }
}
